﻿@model TraCuuThuatNgu.ViewModels.ResultViewModel
@{
    Layout = "~/Views/Shared/_Root.cshtml";               
}
<div class="span span8">
    <div class="head">
        <div class="icm-list">
        </div>
        <h1>
            Kết quả</h1>
        <div class="clear">
        </div>
    </div>
    <div style="min-height:200px;" class="block">
        <div class="first-result">
            @if (Model.Entry != null)
            {
                <h1 id="headWord">@Model.Entry.HeadWord</h1>
                if (User.Identity.IsAuthenticated)
                {
                <div id="like-submit" class="like" title="Yêu thích">
                </div>
                }
                else
                {
                <div id="like-check" class="like like-check" title="Yêu thích">
                </div>
                }
                
                <div class="count-like">
                    @Model.Entry.Favorites.Count</div>
                
            }
            else
            { 
                <p style="float: left">
                    Không tìm thấy</p>
            }
            @if (User.Identity.IsAuthenticated)
            {
                <a style="float: right" href="#" id="add-content-btn" class="btn-link btn-add">Thêm
                    đóng góp</a>
            }
            else
            { 
                <a style="float: right" href="#" id="add-content-check" class="btn-link btn-add like-check">
                    Thêm đóng góp</a>
            }
            <div class="clear">
            </div>
        </div>
        <div class="divider">
        </div>
        <div class="description-result">
            @*<span class="ic-right"></span><span class="description-text">Giải thích</span>*@
            @if (ViewBag.Noun != null)
            {
                <h3 style="color: #f89406">
                    Danh từ</h3>
                foreach (var item in ViewBag.Noun)
                {
                <span class="ic-arrow-right"></span>
                <p>
                    <span class="synset">
                        @foreach (var entry in item.WordIndexes)
                        {
                            if (entry.HeadWord.Equals(Model.Entry.HeadWord))
                            {
                            <span class="synset-item">@entry.HeadWord</span>
                            }
                            else
                            {
                            <span class="synset-item"><a class="btn-link" href="/Result?keyword=@entry.HeadWord">@entry.HeadWord</a></span>
                            }
                        }: </span>
                    <script>                        $("span span").last().removeClass('synset-item');</script>
                    <span class="def">@item.Def
                    </span><span class="exa">Ví dụ: @item.Exa</span>
                </p>
                }
            }
            @if (ViewBag.Verb != null)
            {
                <h3 style="color: #f89406">
                    Động từ</h3>
                foreach (var item in ViewBag.Verb)
                {
                <span class="ic-arrow-right"></span>
                <p>
                    <span class="synset">
                        @foreach (var entry in item.WordIndexes)
                        {
                            if (entry.HeadWord.Equals(Model.Entry.HeadWord))
                            {
                            <span class="synset-item">@entry.HeadWord</span>
                            }
                            else
                            {
                            <span class="synset-item"><a class="btn-link" href="/Result?keyword=@entry.HeadWord">@entry.HeadWord</a></span>
                            }
                        }: </span>
                    <script>                        $("span span").last().removeClass('synset-item');</script>
                    <span class="def">@item.Def</span> <span class="exa">Ví dụ: @item.Exa</span>
                </p>
                }
            }
            @if (ViewBag.Adj != null)
            {
                <h3 style="color: #f89406">
                    Tính từ</h3>
                foreach (var item in ViewBag.Adj)
                {
                <span class="ic-arrow-right"></span>
                <p>
                    <span class="synset">
                        @foreach (var entry in item.WordIndexes)
                        {
                            if (entry.HeadWord.Equals(Model.Entry.HeadWord))
                            {
                            <span class="synset-item">@entry.HeadWord</span>
                            }
                            else
                            {
                            <span class="synset-item"><a class="btn-link" href="/Result?keyword=@entry.HeadWord">@entry.HeadWord</a></span>
                            }
                        }: </span>
                    <script>                        $("span span").last().removeClass('synset-item');</script>
                    <span class="def">@item.Def</span> <span class="exa">Ví dụ: @item.Exa</span>
                </p>
                }
            }
        </div>
        @if (Model.Entry != null)
        {
        <div class="divider">
        </div>
            }
        @* Suggest when keyword not found*@ 
        <div class="description-result">
            <span class="ic-cloud"></span>
            @if (Model.Entry == null)
            {
                <span class="description-text">Gợi ý:</span>
            }else{
             <span class="description-text">Thuật ngữ liên quan:</span>
            }
            @foreach (var item in Model.SuggestTerm)
            {
                if (!item.HeadWord.Equals(Request.QueryString["keyword"]))
                {
                <a class="suggest-term suggest-comma" href="@Url.Content("~/Result?keyword="+@item.HeadWord)">@item.HeadWord</a>
                }
            }
             <script>                 $("a").last().removeClass('suggest-comma');</script>
        </div>
                      
        @if (Model.Entry != null)
        {
            <div class="divider">
            </div>
            <div class="description-result">
                <span class="ic-chat"></span><span class="description-text">Thảo luận</span>
            </div>
       
            <div class="comments">
                <div class="comments-head">
                </div>
                <div class="comment-input">
                    @using (Html.BeginForm("Add", "Comment", FormMethod.Post, new { id = "comment-form" }))
                    {
                        <div class="itemOut">
                            <a href="#" class="image">
                                <img src="@Url.Content("~/Content/img/users/noAvatar.gif")" class="img-polaroid"></a>
                            @if (User.Identity.IsAuthenticated)
                            {                        
                                <input name="headWord" type="hidden" value='@Request.Params["keyword"].ToString()' />
                                <textarea name="content" id="comment-content" class="text"></textarea>
                                
                                //check Authenticate
                                <input type="hidden" value="true" id="checkAuthenComment" />
                            }
                            else
                            { 
                                <div class="text" style="min-height: 75px">
                                    Bạn phải <a class="popUpLogon" href="#">đăng nhập</a> mới có thể bình luận.
                                </div>
                            }
                            <div style="text-align: right">
                                <button class="btn" type="submit">
                                    Gửi</button>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                    }
                </div>
                <div class="dr">
                    <span></span>
                </div>
                @if (Model.Entry.Comments.Count == 0)
                { 
                    <p>
                        Chưa có bình luận nào</p>
                }
                else
                {<p>
                    Có <b>@Model.Entry.Comments.Count</b> bình luận</p>}
                <div class="comments-list">
                    @foreach (var item in Model.Entry.Comments)
                    {   
                        
                        <div class="itemOut">
                            <a href="#" class="image">
                                <img src="@Url.Content("~/Content/img/users/noAvatar.gif")" class="img-polaroid"></a>
                            <div class="text">
                                <div class="info">
                                    <span class="name">@item.aspnet_Users.UserName</span> <a style="float:right;margin-left:10px" title="Báo cáo sai phạm" class="btn-report mark-report" data-val="@item.CommentId"  href="javascript:">
                                    </a><span class="date">@String.Format("{0:d/M/yyyy HH:mm}", item.DateAdd)</span>
                                    <div class="clear">
                                    </div>
                                </div>
                                @item.CmContent
                            </div>
                            <div class="clear">
                            </div>
                        </div>                
                    }
                </div>
            </div>
        }
        else
        {

        }
    </div>
</div>
<div class="span span9">
        <div class="block block-sumary alphabet-work">
            <div class="sumary aphab-list">
                <a class="alphabet-link" href="@Url.Content("~/Alphabet")">Tra cứu theo thứ tự bảng chữ cái</a>                 
            </div>
        </div>
</div>
<div class="span span9">
    <div class="head">
        <div class="icm-zoom">
        </div>
        <h1>
            Tra cứu gần đây</h1>
        <div class="clear">
        </div>
    </div>
    <div class="block">
        <div class="recent-words">
            <ul>
                @{
                    ((List<string>)Session["Recent"]).Reverse();
                }
                @foreach (var item in (List<string>)Session["Recent"])
                { 
                    <li><a href="@Url.Content("~/Result?keyword="+@item)">@item</a></li>  
                }
                @{
                    ((List<string>)Session["Recent"]).Reverse();
                }
            </ul>
        </div>
    </div>
</div>
<div class="span span9">
    <div class="head">
        <div class="icm-chats">
        </div>
        <h1>
            Hỏi đáp nhanh</h1>
        <div class="clear">
        </div>
    </div>
    <div class="block">
       @Html.Partial("_QA",Model.Questions)
    </div>
</div>
<div class="clear">
</div>
@Html.Partial("_LogOnPopUp", Model.LogOnModel)
@Html.Partial("_AddContent", Model.LogOnModel)
